package com.bss.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

@Entity
@Table(name = "attendent")
public class Attendent extends Person {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8842931510471947798L;

	@NotNull(message = "{attendent.name.NotNull}")
	@Size(min = 1, max = 45, message = "{attendent.name.Size}")
	private String name;

	private Relationship relationship = new Relationship();

	private Patient patient = new Patient();

	private Set<CurrentAttendent> currentAttendents = new HashSet<CurrentAttendent>(0);

	public void setCurrentAttendents(final Set<CurrentAttendent> currentAttendents) {
		this.currentAttendents = currentAttendents;
	}

	@NotNull(message = "{attendent.relationship.NotNull}")
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idRelationship")
	public Relationship getRelationship() {
		return this.relationship;
	}

	public void setRelationship(final Relationship relationship) {
		this.relationship = relationship;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "idPatient")
	public Patient getPatient() {
		return this.patient;
	}

	public void setPatient(final Patient patient) {
		this.patient = patient;
	}

	public void setName(final String name) {
		this.name = name;
	}

	@Column(name = "name", nullable = false, length = 45)
	public String getName() {
		return this.name;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "attendent")
	public Set<CurrentAttendent> getCurrentAttendents() {
		return this.currentAttendents;
	}

}
